package com.qf.utils;



import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

/**
 * 【随机数工具类】
 */
public class RandomUtil {
//    public static void main(String[] args) {
//        String s=getTime();
//        System.out.println(s);
//    }
    //生成激活码
    public static String createActiveCode(){
        Random random = new Random();
        return getTime()+Integer.toHexString(random.nextInt(9999999));
    }
    //获取当前时间
    public static String getTime(){
        DateTimeFormatter formatter  = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
        return LocalDateTime.now().format(formatter);
    }
    //生成随机订单号
    public static String createOrderId(){
        return getTime()+new Random().nextInt(9999999);
    }

}
